<layout name="Iflayout"/>
<div class="xyh-content">
    <div class="row">
        <div class="col-lg-12">
            <h3 class="page-header"><em class="glyphicon glyphicon-cloud-upload"></em>
                产品回收站
                <span class="xyh-pos">
                <i class="glyphicon glyphicon-log-out"></i>
                </span>
            </h3>
        </div>
    </div>

    <div class="row margin-botton">
        <div class="col-sm-6 column">
            <a class="btn-group btn-group-md">
                <a href="{:U('Product/index')}"><button class="btn btn-primary" type="button"><em class="glyphicon glyphicon-chevron-left"></em> 返回</button></a>
                <a href=""><button class="btn btn-default" type="button"><em class="glyphicon glyphicon-retweet"></em> 还原</button></a>
                <a href="javascript:void(0)"><button class="btn delete" type="button"><em class="glyphicon glyphicon-remove-circle"></em> 彻底删除</button></a>
            </div>
        </div>
        <div class="col-sm-6 text-right">
        </div>
    </div>

    <div class="row">
        <div class="col-lg-12">
            <form action="" method="post" id="form_do" name="form_do">
                <div class="table-responsive">
                    <table class="table table-hover xyh-table-bordered-out">
                        <thead>
                        <tr class="active">
                            <th><input type="checkbox" id="check"></th>
                            <th>编号</th>
                            <th>标题</th>
                            <th>分类</th>
                            <th>点击数</th>
                            <th>发布时间</th>
                            <th class="text-right">操作</th>
                        </tr>
                        </thead>
                        <tbody>

                        <foreach name="list" item="arr">
                        <tr>
                            <td><input type="checkbox" name="key[]" value="{$arr['id']}" class="checkbox"></td>
                            <td>{$arr['id']}</td>
                            <td class="aleft" style="color:#ed008c">{$arr['title']}<span style="color:#079B04;">[图片]</span></td>
                            <td>{$arr['name']}</td>
                            <td>{$arr['click']}</td>
                            <td>{$arr['publishtime']|date='Y-m-d H:i:s',###}</td>
                            <td class="text-right">
                                <a href="{:U('Product/haiy',array('id'=>$arr['id']))}" class="label label-info">还原</a>
                                <a href="javascript:void(0)"  class="label label-danger" m="{$arr['id']}">彻底删除</a>
                            </td>
                        </tr>
                        </foreach>
                        </tbody>
                    </table>
                </div>
            </form>

            <div class="row clearfix">
                <div class="col-md-12 column">
                    <div class="xyh-page">
                        <div><span class="rows">共 {$count} 条记录</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>



<script type="text/javascript">

    $('.btn-default').click(function(){

        if ($('.checkbox:checked').length==0) {
            alert('至少选择一个');
        }else{
            var arr =[];
            $('.checkbox:checked').each(function(i){
                arr[i] = $(this).val();
            })

            if(confirm('确定还原?')) {

                $.post("{:U('Product/haiy')}", {'id': arr}, function (date) {
                    if (date == 1) {
                        alert('还原成功');
                        $('checkbox[name="key"]:checked').parent().parent().remove();
                    } else {
                        alert('还原失败');
                    }
                })
            }
        }
    })

</script>




<script>
    $(function(){
        $('.label-danger').click(function(){
            if(confirm('确定删除?')){
                var _id = $(this).attr('m');
                var _this = $(this);
                $.post("{:U('Product/delete')}", {id:_id}, function(data){
                    if(data){
                        alert('删除成功');
                        _this.parent().parent().remove();
                    }else{
                        alert('删除失败');
                    }
                })
            }
        })
    })
</script>



<script type="text/javascript">

    $('.delete').click(function(){
        if ($('.checkbox:checked').length==0) {
            alert('至少选择一个');
        }else{
            var arr =[];
            $('.checkbox:checked').each(function(i){
                arr[i] = $(this).val();
            })

            if(!confirm('确定删除?')){
                alert('删除失败');
            }
            $.post("{:U('Product/delete')}",{id:arr},function(date){
                if(date.status=1){
                    alert(date.info);
                    $('.checkbox:checked').parent().parent().remove();
                }
            })
        }

    })

</script>

